#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <set>

using namespace std;

class Solution {
    public:
        string longestCommonPrefix(vector<string> &strs) {
            string ans;
            int  pos = 0;
            if (strs.size() == 0) return ans;
            while(1) {
                for (int i = 0; i < strs.size(); i++) {
                    if (pos >= strs[i].size()) return ans;
                    if (strs[i][pos] != strs[0][pos]) return ans; 
                }
                ans += strs[0][pos];
                pos++;
            }
        }
};

int main(int argc, char **argv)
{
    Solution mySolution;
    string result;

    cout << "-----------------Test 1--------------------" << endl;
    vector<string> input;
    input.push_back("abc");
    input.push_back("abcd");
    input.push_back("abce");
    input.push_back("abcf");
    input.push_back("abcghi");
    result = mySolution.longestCommonPrefix(input);
    cout << result << endl;

    cout << "-----------------Test 2--------------------" << endl;
    vector<string> input1;
    input1.push_back("");
    input1.push_back("abc");
    input1.push_back("abcd");
    input1.push_back("abcef");
    input1.push_back("abcfh");
    input1.push_back("abcghi");
    result = mySolution.longestCommonPrefix(input1);
    cout << result << endl;


    cout << "-----------------Test 3--------------------" << endl;
    vector<string> input2;
    input2.push_back("a");
    input2.push_back("a");
    input2.push_back("b");
    result = mySolution.longestCommonPrefix(input2);
    cout << result << endl;


    cout << "-----------------Test 4--------------------" << endl;


    cout << "-----------------Test 5--------------------" << endl;



}
